package com.jielihaofeng.context;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Johnnie Wind
 * @description Context 写作手法
 * @date 2022/1/11 10:38
 */
public class Morning implements MeetContext {

    private Asker asker;
    private Answer answer;

    private List<String> event = new ArrayList<>(1);

    public Morning() {

    }

    @Override
    public void meet() {
        String msg = "Did you have breakfast?";
        asker.ask(msg);
        answer.anwser();
    }

    public void setAsker(Asker asker) {
        this.asker = asker;
    }

    public void setAnswer(Answer answer) {
        this.answer = answer;
    }

    class Asker {
        public void ask(String msg) {
            event.add(msg);
            System.out.println("Asker：" + msg);
        }
    }

    class Answer {
        public void anwser() {
            String msg = event.get(0);
            System.out.println("Answer get Asker question：" + msg);
        }
    }

    public static void main(String[] args) {

        Morning morning = new Morning();

        Asker asker = morning.new Asker();
        Answer answer = morning.new Answer();

        morning.setAsker(asker);
        morning.setAnswer(answer);

        morning.meet();
    }
}
